package com.ellricky.baselib.ui.base;

import android.app.Activity;

import com.andr.common.ui.activity.BaseToolBarActivity;
import com.ellricky.baselib.BaseConstant;
import com.ellricky.baselib.R;
import com.ellricky.baselib.mvp.BaseDetailPresenter;
import com.ellricky.baselib.mvp.BaseDetailView;
import com.ellricky.baselib.widget.CommonDetailView;

public abstract class BaseDetailActivity
        extends BaseToolBarActivity<BaseDetailView, BaseDetailPresenter>
        implements BaseDetailView {

    private CommonDetailView detailView;

    protected String id;

    @Override
    public int getContentLayout() {
        return R.layout.base_activity_detail;
    }

    @Override
    public Activity getAct() {
        return this;
    }

    @Override
    public BaseDetailPresenter createPresenter() {
        return new BaseDetailPresenter(this);
    }

    @Override
    public void initUIView() {
        super.initUIView();
        detailView = findViewById(R.id.detailView);
        if (detailView != null) {
            int childLayout = getChildContentLayout();
            if (childLayout > 0) {
                detailView.setContentView(childLayout);
            }
        }

        id = getIntent().getStringExtra(BaseConstant.KEY_ID);
    }


    protected int getChildContentLayout() {
        return 0;
    }

    @Override
    public void onBackPage(int resultCode) {
        setResult(resultCode);
        finish();
    }
}
